<%@ page import="utils.StringUtils" %>
<%@ page import="database.ClassDb" %>
<%@ page import="database.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: jimmyhsu
  Date: 2016/12/12
  Time: 21:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../../static/style/weui.css"/>
    <link rel="stylesheet" href="../../static/example/example.css"/>
    <link rel="stylesheet" href="../../static/style/myStyle.css"/>
    <%
        String classIdStr = request.getParameter("classId");
        List<User> usersInClass = new ArrayList<User>();
        boolean avail = true;
        int classId = -1;
        if (StringUtils.isEmpty(classIdStr) || classIdStr.equals("null")) {
            avail = false;
        }
        if (avail) {
            classId = Integer.parseInt(classIdStr);

            if (!StringUtils.isEmpty(request.getParameter("refresh"))
                    && !request.getParameter("refresh").equals("null")
                    && request.getParameter("refresh").equals("true")) {
                response.getWriter().print("<script>window.parent.left_frame.location.href='importClassLeft.jsp?classId=" + classId + "';</script>");
            }
            usersInClass = ClassDb.selectUserInClassByClassId(classId);
        }
    %>
</head>
<body style="background-color: transparent; color: #ffffff;">
<center>
    <h3>当前成员</h3>
    <table class='zebra'>
        <%
for (User user : usersInClass){%>
        <tr>
            <td><%=user.getId()%></td>
            <td><%=user.getName()%></td>
            <td><button class="weui_btn weui_btn_mini weui_btn_default" style = "position: relative" onclick="onRemove('<%=user.getId()%>','<%=classId%>')">移除</button></td>
        </tr>
        <%
}%>
    </table>
</center>
</body>
<script>
    function onRemove(userId, classId) {
        if (window.confirm("将要把这个学生从此班级中删除。确定吗?")) {
            location.href = 'removeUserInClass?userId=' + userId + '&classId=' + classId;
        }
    }
</script>
</html>
